<template>
  <div>
    <van-tabs v-model="active" @click="change">
      <van-tab
        v-for="(item, index) in tab"
        :key="index"
        :title="item.title"
        :name="item.tab"
      ></van-tab>
    </van-tabs>
    <appList :list="list" />
  </div>
</template>

<script>

import appList from "./appList.vue"

export default {
  components: {
      appList
  },
  data() {
    return {
      active:"share",
      tab: [
        {
          title: "全部",
          tab: "all",
        },
        {
          title: "精华",
          tab: "pure",
        },
        {
          title: "分享",
          tab: "share",
        },
        {
          title: "问答",
          tab: "ask",
        },
        {
          title: "招聘",
          tab: "order",
        },
        {
          title: "客户端测试",
          tab: "user",
        },
      ],
      list: [],
      res:''
    };
  },
  mounted() {
    this.change();
  },
  methods: {
    change(tab) {
      localStorage.setItem("tab", this.active);
      this.list = [],
        this.$http("/list.json", "get").then((res) => {
            console.log(res.data.data);
          this.list=res.data.data.filter(res=>{
             return res.tab==this.active
          })
          console.log(this.list);
        });
    },
  },
};
</script>